<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "tag_and_article".
 *
 * @property integer $tag_id
 * @property integer $model_id
 */
class TagAndArticle extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'tag_and_article';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['tag_id', 'model_id'], 'required'],
            [['tag_id', 'model_id', 'ord'], 'integer'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'tag_id' => '标签id',
            'model_id' => '文章id',
            'ord' => '排序',
        ];
    }
    public function getTags()
    {
        return $this->hasOne(Tag::className(),['id'=>'tag_id']);
    }
}
